<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	//获得本项目的地址(例如: http://localhost:8080/MyApp/)赋值给basePath变量    
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="logincss/styles.css">
<script type="text/javascript" src="loginjs/jquery-2.1.1.min.js"></script>

<script type="text/javascript">

	function validate () {
		var inputCode = document.getElementById("input1").value.toUpperCase();
		if(inputCode.length <=0) {
		   alert("请输入验证码！");
		   return false;
		}else if(inputCode != code ){
		   alert("验证码输入错误！");
		   createCode();
		   return false;
		}else {
		  // alert("成功！");
		   validateParam();
		   return true;
		}
	}
	
</script>

</head>
<title>登录</title>
<body>


	<div class="wrapper">

		<div class="container">
			<h1>Welcome</h1>
			<form id="loginForm" action="<%=basePath %>userLogin" onsubmit="return validate()"
				method="post">
				<input id="user_name" name="userName" type="text" placeholder="userName"> 
				<input id="user_pwd" name="password" type="password" placeholder="password"> 
				<input id="loginbutton" type="submit" value="submit" />
				<p id="error_msg" style="margin: 0 auto; margin-top: 0.2em; width: 20em; font-size: 0.8em; z-index: 99; color: #FF3333;"></p>
			</form>
		</div>


		<ul class="bg-bubbles">
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
		</ul>

	</div>


	<script type="text/javascript">
		

		function tabUserLogin() {
			var user_name = $("#user_name").val();
			var user_pwd = $("#user_pwd").val();
			if (user_name != "" && user_pwd != "") {
				$.ajax({
					type : 'post',
					url : '<%=basePath%>web/admin/tabUser/tabUserLogin',
					data : {
						user_name : user_name,
						user_pwd : user_pwd
					},
					success : function(data) {
						if (data.success) {
							window.location.href="<%=basePath%>
		index.jsp";
						} else {
							$("#error_msg").text("用户名或密码错误");
						}
					}
				});
			} else {
				$("#error_msg").text("登录信息不能为空");
			}
		}
	</script>

</body>
</html>